package com.java.test.activity.activitypush;

import com.java.test.activity.activitypush.dto.AddActivityDTO;
import com.java.test.controller.BaseController;
import com.java.test.dto.ResponseDTO;
import com.java.test.messagecenter.messagepush.dto.SendMailDTO;
import com.java.test.system.dto.LoginAccountInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 活动推送Controller
 *
 * @author lijie1
 * @date 2020/7/10 0010
 */
@Slf4j
@RestController
@RequestMapping("/activityPush")
public class ActivityPushController extends BaseController {
    ActivityPushService activityPushService;
    @Autowired
    public void setActivityPushService(ActivityPushService activityPushService) {
        this.activityPushService = activityPushService;
    }

    /**
     * 消息推送
     * @author lijie1
     * @date 2020/7/10 0010
     */
    @RequestMapping(value = "/addActivity",method = RequestMethod.POST)
    public ResponseDTO<String> addActivity(@RequestBody @Valid AddActivityDTO dto, HttpServletRequest request) {
        log.debug("----------消息推送----------");
        LoginAccountInfo user = (LoginAccountInfo) request.getSession().getAttribute("user");
        systemManageService.insertlogInfo(user.getLoginAccout(), user.getIp(), "消息中心-推送管理-推送消息"+dto.getTitle());
        return activityPushService.addActivity(dto);
    }
}
